
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('eyeData produces correct results liang_g_n_approx', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results liang_g_n_approx')
    result <- sampler(100000, vy, mX, prior='liang_g_n_approx', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.002960000000000000,0.004160000000000000,0.001310000000000000,
0.001590000000000000,0.002410000000000000,0.003000000000000000,
0.001210000000000000,0.003320000000000000,0.001470000000000000,
0.001790000000000000,0.052209999999999999,0.002880000000000000,
0.002450000000000000,0.001700000000000000,0.001260000000000000,
0.002790000000000000,0.001180000000000000,0.001370000000000000,
0.002160000000000000,0.001140000000000000,0.001270000000000000,
0.001370000000000000,0.001810000000000000,0.001300000000000000,
0.001210000000000000,0.003060000000000000,0.001410000000000000,
0.008619999999999999,0.001170000000000000,0.002900000000000000,
0.003710000000000000,0.001170000000000000,0.002280000000000000,
0.001510000000000000,0.001420000000000000,0.005520000000000000,
0.001330000000000000,0.002250000000000000,0.001370000000000000,
0.001290000000000000,0.001360000000000000,0.036740000000000002,
0.001400000000000000,0.001310000000000000,0.001200000000000000,
0.001600000000000000,0.001310000000000000,0.001250000000000000,
0.001990000000000000,0.004840000000000000,0.001440000000000000,
0.002950000000000000,0.001250000000000000,0.008910000000000000,
0.008370000000000001,0.001010000000000000,0.001500000000000000,
0.001810000000000000,0.002330000000000000,0.008619999999999999,
0.001200000000000000,0.024260000000000000,0.001850000000000000,
0.002020000000000000,0.001670000000000000,0.006400000000000000,
0.001560000000000000,0.001310000000000000,0.001100000000000000,
0.001610000000000000,0.012140000000000000,0.001340000000000000,
0.001530000000000000,0.001760000000000000,0.001390000000000000,
0.015869999999999999,0.001500000000000000,0.002360000000000000,
0.001190000000000000,0.001560000000000000,0.001270000000000000,
0.001320000000000000,0.001420000000000000,0.001600000000000000,
0.004030000000000000,0.001540000000000000,0.157810000000000006,
0.001710000000000000,0.001950000000000000,0.018720000000000001,
0.001180000000000000,0.004500000000000000,0.002380000000000000,
0.001110000000000000,0.001450000000000000,0.003660000000000000,
0.001540000000000000,0.001270000000000000,0.012489999999999999,
0.001820000000000000,0.001920000000000000,0.007860000000000001,
0.001050000000000000,0.002790000000000000,0.001400000000000000,
0.001570000000000000,0.003030000000000000,0.003260000000000000,
0.021319999999999999,0.007420000000000000,0.003390000000000000,
0.013760000000000000,0.003280000000000000,0.001420000000000000,
0.001450000000000000,0.001350000000000000,0.003040000000000000,
0.001100000000000000,0.001280000000000000,0.001410000000000000,
0.001540000000000000,0.001090000000000000,0.005930000000000000,
0.002510000000000000,0.006840000000000000,0.001280000000000000,
0.009070000000000000,0.001430000000000000,0.001430000000000000,
0.001410000000000000,0.001470000000000000,0.007570000000000000,
0.001120000000000000,0.006760000000000000,0.003880000000000000,
0.022270000000000002,0.002250000000000000,0.001360000000000000,
0.001550000000000000,0.008550000000000000,0.009560000000000001,
0.001230000000000000,0.001650000000000000,0.001280000000000000,
0.001400000000000000,0.005950000000000000,0.007030000000000000,
0.002900000000000000,0.001190000000000000,0.001260000000000000,
0.002390000000000000,0.002150000000000000,0.958139999999999992,
0.004770000000000000,0.027760000000000000,0.001470000000000000,
0.007140000000000000,0.007020000000000000,0.013169999999999999,
0.001630000000000000,0.004960000000000000,0.005630000000000000,
0.002340000000000000,0.014310000000000000,0.001910000000000000,
0.001630000000000000,0.001050000000000000,0.002020000000000000,
0.001150000000000000,0.003200000000000000,0.001350000000000000,
0.020930000000000001,0.003320000000000000,0.001720000000000000,
0.003150000000000000,0.002120000000000000,0.005870000000000000,
0.001230000000000000,0.002030000000000000,0.784760000000000013,
0.055120000000000002,0.016410000000000001,0.006210000000000000,
0.003860000000000000,0.765490000000000004,0.001490000000000000,
0.040500000000000001,0.008290000000000000,0.002840000000000000,
0.002650000000000000,0.001550000000000000,0.001300000000000000,
0.001130000000000000,0.001300000000000000,0.001240000000000000,
0.003050000000000000,0.001480000000000000,0.002020000000000000,
0.003400000000000000,0.047879999999999999
)
, tolerance = 1e-8)
})